//645. 错误的集合

int cmp_int(const void* p1, const void* p2){
    return *(int*)p1 - *(int*)p2;
}
int* findErrorNums(int* nums, int numsSize, int* returnSize){
    qsort(nums, numsSize, sizeof(int), cmp_int);
    int* ret = (int*)malloc(sizeof(int) * 2);
    *returnSize = 2;
    int prev = 0;
    for(int i = 0; i < numsSize; i++)
    {
        int cur = nums[i];
        if(cur == prev)
        {
            ret[0] = prev; 
        }
        else if(cur - prev > 1)
        {
            ret[1] = prev + 1;//这里解决右边界与第二个重复的位置
        }
        prev = cur;
    }
    if(nums[numsSize-1] != numsSize)//这里解决左边界
        ret[1] = numsSize;

    return ret;
}